package com.jzg.jcptadmin.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.base.BaseActivity;
import com.jzg.jcptadmin.constant.Constant;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by jzg on 2016/1/8.
 * 单选界面
 */
public class RadioActivity extends BaseActivity {
    @Bind(R.id.rb_jingzhengu)
    RadioButton rbJingzhengu;
    @Bind(R.id.rb_juedangche)
    RadioButton rbJuedangche;
    @Bind(R.id.rb_yiqidazhong)
    RadioButton rbYiqidazhong;
    @Bind(R.id.rb_duopingtai)
    RadioButton rbDuopingtai;
    private String status;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio);
        ButterKnife.bind(this);

        status = getIntent().getStringExtra(Constant.ACTIVITY_RADIO);

        initView();
       // initData();
    }

    private void initData() {
    }

    private void initView() {
        if(status!=null){
            if(status.equals("1")){
                rbJingzhengu.setChecked(true);
            }else if(status.equals("2")){
                rbJuedangche.setChecked(true);
            }else if(status.equals("3")){
                rbYiqidazhong.setChecked(true);
            }else if(status.equals("4")){
                rbDuopingtai.setChecked(true);
            }
        }
    }
    //保存监听
   public void onSave(View view){
       Intent intent = new Intent();
       if(rbJingzhengu.isChecked()){
           intent.putExtra(Constant.ACTIVITY_RADIO,1);
           intent.putExtra(Constant.ACTIVITY_RADIONAME,rbJingzhengu.getText().toString());
       }else if(rbJuedangche.isChecked()){
           intent.putExtra(Constant.ACTIVITY_RADIO,2);
           intent.putExtra(Constant.ACTIVITY_RADIONAME,rbJuedangche.getText().toString());
       }else if(rbYiqidazhong.isChecked()){
           intent.putExtra(Constant.ACTIVITY_RADIO,3);
           intent.putExtra(Constant.ACTIVITY_RADIONAME,rbYiqidazhong.getText().toString());
       }else if(rbDuopingtai.isChecked()){
           intent.putExtra(Constant.ACTIVITY_RADIO,4);
           intent.putExtra(Constant.ACTIVITY_RADIONAME,rbDuopingtai.getText().toString());
       }

       setResult(Activity.RESULT_OK,intent);
       finish();

    }

}
